package com.twu.biblioteca;

import java.util.ArrayList;

import static javax.swing.JOptionPane.showMessageDialog;

/**
 * Created with IntelliJ IDEA.
 * User: Deepika
 * Date: 5/31/13
 * Time: 12:29 AM
 * To change this template use File | Settings | File Templates.
 */
class BibliotecaLibrary{

    ArrayList<Book> books = new ArrayList<Book>();

    public void initialiseBooks() {
        Book b1 = new Book("Gone with the Wind",0);
        Book b2 = new Book("Sherlock Homes",1);
        books.add(b1);
        books.add(b2);
    }


    public boolean reserveBooks(Integer index){

        Book b = books.get(index);
        if(b.checkAvailability() == 0){
            showMessageDialog(null, "Sorry we don't have that book yet.");
            return(false);
        }
        else  {
            showMessageDialog(null, "Thank You! Enjoy the book.");
            b.issueBook();
            return(true);
        }
    }

    BibliotecaLibrary(){
        initialiseBooks();
    }

    public ArrayList<Book> getAllBooks() {
        return books;
    }

}
